package me.sdevil507.platform.po;


import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import me.sdevil507.supports.jpa.BaseJpaSnowflakeIdAndAuditEntity;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 平台部门表[PlatDeptPo]
 *
 * @author sdevil507
 * created on 2020-06-24 14:29:16
 */
@Entity
@Table(name = "plat_dept")
@Data
@EqualsAndHashCode(callSuper = true, exclude = {"users"})
@ToString(exclude = {"users"})
public class PlatDeptPo extends BaseJpaSnowflakeIdAndAuditEntity {

    /**
     * 部门名称
     */
    @Column
    private String title;

    /**
     * 部门编码
     */
    @Column
    private String code;

    /**
     * 机构父ID
     */
    @Column
    private Long parentId;

    /**
     * 同级排序
     */
    @Column
    private int sortNum;

    /**
     * 是否是智库
     */
    @Column
    private int isOrg;

    /**
     * 同级排序
     */
    @Column
    private Long orgId;

    /**
     * 子机构
     */
    @OneToMany(cascade = CascadeType.REMOVE)
    @JoinColumn(name = "parentId", foreignKey = @ForeignKey(name = "none"))
    @OrderBy("sortNum ASC")
    private List<PlatDeptPo> children = new ArrayList<>(20);

}